<%--
  Created by IntelliJ IDEA.
  User: XYC
  Date: 2015/7/22
  Time: 11:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<link rel="stylesheet" href="${dean}/css/family.css" type="text/css"/>
<html>
<head>
</head>
<body>
<div class="genetic">
	<div id="relation1" class="relate">
		<span class="role"></span>
		<div  class="judge judge1">
			<span>
				<input type="radio" name="judgement1" id="No1"/>
				<label for="No1">无</label>
			</span>
			<span>
				<input type="radio" name="judgement1" id="Yes1" />
				<label for="Yes1">有</label>
			</span>
		</div>
		<div class="choice choice1">
			<span class="w77">
				<input type="checkbox" name="disease" id="HighBlood1" value="1" disabled="disabled"/>
				<label for="HighBlood1">高血压</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="cancer1" value="5" disabled="disabled"/>
				<label for="cancer1">恶性肿瘤</label>
			</span>
			<span class="w90">
				<input type="checkbox" name="disease" id="stroke1" value="6" disabled="disabled"/>
				<label for="stroke1">脑卒中</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="psychosis1" value="7" disabled="disabled"/>
				<label for="psychosis1">重性精神疾病</label>
			</span>
			<br />
			<br />
			<span class="w77">
				<input type="checkbox" name="disease" id="Coronary1" value="3" disabled="disabled"/>
				<label for="Coronary1">冠心病</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="Chronic1" value="4" disabled="disabled"/>
				<label for="Chronic1">慢性阻塞性疾病</label>
			</span>
			<span class="w90">
				<input type="checkbox" name="disease" id="Liver1" value="9" disabled="disabled"/>
				<label for="Liver1">肝脏疾病</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="malformations1" value="10" disabled="disabled"/>
				<label for="malformations1">先天畸形</label>
			</span>
			<br />
			<br />
			<span class="w77">
				<input type="checkbox" name="disease" id="diabetes1" value="2" disabled="disabled"/>
				<label for="diabetes1">糖尿病</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="Tuberculosis1" value="8" disabled="disabled"/>
				<label for="Tuberculosis1">结核病</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="other1" value="11" disabled="disabled"/>
				<label for="other1">其他</label>
				<!-- <input type="text" value="其他"  class="Other" disabled="disabled"/> -->
			</span>
		</div>
	</div>
	<div class="cl"></div>
	<div id="relation2" class="relate">
		<span class="role1"></span>
		<div class="judge  judge2">
			<span>
				<input type="radio" name="judgement2" id="No2" />
				<label for="No2">无</label>
			</span>
			<span>
				<input type="radio" name="judgement2" id="Yes2" />
				<label for="Yes2">有</label>
			</span>
		</div>
		<div class="choice choice2">
			<span class="w77">
				<input type="checkbox" name="disease" id="HighBlood2" value="1" disabled="disabled"/>
				<label for="HighBlood2">高血压</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="cancer2" value="5" disabled="disabled"/>
				<label for="cancer2">恶性肿瘤</label>
			</span>
			<span class="w90">
				<input type="checkbox" name="disease" id="stroke2" value="6" disabled="disabled"/>
				<label for="stroke2">脑卒中</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="psychosis2" value="7" disabled="disabled"/>
				<label for="psychosis2">重性精神疾病</label>
			</span>
			<br />
			<br />
			<span class="w77">
				<input type="checkbox" name="disease" id="Coronary2" value="3" disabled="disabled"/>
				<label for="Coronary2">冠心病</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="Chronic2" value="4" disabled="disabled"/>
				<label for="Chronic2">慢性阻塞性疾病</label>
			</span>
			<span class="w90">
				<input type="checkbox" name="disease" id="Liver2" value="9" disabled="disabled"/>
				<label for="Liver2">肝脏疾病</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="malformations2" value="10" disabled="disabled"/>
				<label for="malformations2">先天畸形</label>
			</span>
			<br />
			<br />
			<span class="w77">
				<input type="checkbox" name="disease" id="diabetes2" value="2" disabled="disabled"/>
				<label for="diabetes2">糖尿病</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="Tuberculosis2" value="8" disabled="disabled"/>
				<label for="Tuberculosis2">结核病</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="other2" value="11" disabled="disabled"/>
				<label for="other2">其他</label>
				<!-- <input type="text" value="其他"  class="Other" disabled="disabled"/> -->
			</span>
		</div>
	</div>
	<div class="cl"></div>
	<div id="relation3" class="relate">
		<span class="role2"></span>
		<div class="judge  judge3">
			<span>
				<input type="radio" name="judgement3" id="No3" />
				<label for="No3">无</label>
			</span>
			<span>
				<input type="radio" name="judgement3" id="Yes3" />
				<label for="Yes3">有</label>
			</span>
		</div>
		<div class="choice choice3">
			<span class="w77">
				<input type="checkbox" name="disease" id="HighBlood3" value="1" disabled="disabled"/>
				<label for="HighBlood3">高血压</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="cancer3" value="5" disabled="disabled"/>
				<label for="cancer3">恶性肿瘤</label>
			</span>
			<span class="w90">
				<input type="checkbox" name="disease" id="stroke3" value="6" disabled="disabled"/>
				<label for="stroke3">脑卒中</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="psychosis3" value="7" disabled="disabled"/>
				<label for="psychosis3">重性精神疾病</label>
			</span>
			<br />
			<br />
			<span class="w77">
				<input type="checkbox" name="disease" id="Coronary3" value="3" disabled="disabled"/>
				<label for="Coronary3">冠心病</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="Chronic3" value="4" disabled="disabled"/>
				<label for="Chronic3">慢性阻塞性疾病</label>
			</span>
			<span class="w90">
				<input type="checkbox" name="disease" id="Liver3" value="9" disabled="disabled"/>
				<label for="Liver3">肝脏疾病</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="malformations3" value="10" disabled="disabled"/>
				<label for="malformations3">先天畸形</label>
			</span>
			<br />
			<br />
			<span class="w77">
				<input type="checkbox" name="disease" id="diabetes3" value="2" disabled="disabled"/>
				<label for="diabetes3">糖尿病</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="Tuberculosis3" value="8" disabled="disabled"/>
				<label for="Tuberculosis3">结核病</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="other3" value="11" disabled="disabled"/>
				<label for="other3">其他</label>
				<!-- <input type="text" value="其他"  class="Other" disabled="disabled"/> -->
			</span>
		</div>
	</div>
	<div class="cl"></div>
	<div id="relation4" class="relate relateLast">
		<span class="role3"></span>
		<div class="judge judge4">
			<span>
				<input type="radio" name="judgement4" id="No4" />
				<label for="No4">无</label>
			</span>
			<span>
				<input type="radio" name="judgement4" id="Yes4" />
				<label for="Yes4">有</label>
			</span>
		</div>
		<div class="choice choice4">
			<span class="w77">
				<input type="checkbox" name="disease" id="HighBlood4" value="1" disabled="disabled"/>
				<label for="HighBlood4">高血压</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="cancer4" value="5" disabled="disabled"/>
				<label for="cancer4">恶性肿瘤</label>
			</span>
			<span class="w90">
				<input type="checkbox" name="disease" id="stroke4" value="6" disabled="disabled"/>
				<label for="stroke4">脑卒中</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="psychosis4" value="7" disabled="disabled"/>
				<label for="psychosis4">重性精神疾病</label>
			</span>
			<br />
			<br />
			<span class="w77">
				<input type="checkbox" name="disease" id="Coronary4" value="3" disabled="disabled"/>
				<label for="Coronary4">冠心病</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="Chronic4" value="4" disabled="disabled"/>
				<label for="Chronic4">慢性阻塞性疾病</label>
			</span>
			<span class="w90">
				<input type="checkbox" name="disease" id="Liver4" value="9" disabled="disabled"/>
				<label for="Liver4">肝脏疾病</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="malformations4" value="10" disabled="disabled"/>
				<label for="malformations4">先天畸形</label>
			</span>
			<br />
			<br />
			<span class="w77">
				<input type="checkbox" name="disease" id="diabetes4" value="2" disabled="disabled"/>
				<label for="diabetes4">糖尿病</label>
			</span>
			<span class="w132">
				<input type="checkbox" name="disease" id="Tuberculosis4" value="8" disabled="disabled"/>
				<label for="Tuberculosis4">结核病</label>
			</span>
			<span>
				<input type="checkbox" name="disease" id="other4" value="11" disabled="disabled"/>
				<label for="other4">其他</label>
				<!-- <input type="text" value="其他"  class="Other" disabled="disabled"/> -->
			</span>
		</div>
	</div>
	<div class="store">
		<button onclick="saveData()" style="  margin-left: 375px;">保存</button>
	</div>
</div>
<%--<script type="text/javascript" src="${js}/jquery.min.js" charset="UTF-8"></script>--%>
<%--<script src="${js}/jquery.min.js"></script>--%>
<script src="${dean}/js/baseDell.js"></script>
<script src="${dean}/js/jquery-1.11.1.min.js"></script>
<script src="${dean}/js/family.js" type="text/javascript"></script>
<script src="${js}/dean.js" type="text/javascript"></script>
<script type="text/javascript">
	var familyHistories=${familyHistories};
	var dataNum;

	function changeDataNeed(familyRelativeNum){
		if(familyRelativeNum==1){
			dataNum="1";
			return;
		}
		if(familyRelativeNum==2){
			dataNum="2";
			return;
		}
		if(familyRelativeNum==8){
			dataNum="3";
			return;
		}
		if(familyRelativeNum==7){
			dataNum="4";
			return;
		}
	}
//relation
	function dellShowContent(familyHistory){
		var arrayTemp = familyHistory.disease;
		if(arrayTemp==""){
			$('#No'+dataNum).prop('checked',true);
			return ;
		}
		$('#Yes'+dataNum).prop('checked',true);
		var strs = arrayTemp.split("|");
		for(var i=0;i<strs.length-1;i++){
			$("#relation"+dataNum+" input[value='"+strs[i]+"']").prop('checked',true);
		}

		$("#relation"+dataNum+" input").removeAttr('disabled','disabled');
	}

	$(document).ready(function(){
		buttonInit(".store button");
		if(familyHistories==""){
			return;
		}
		for(var i=0;i<familyHistories.length;i++){
			var familyHistory =  familyHistories[i];
			changeDataNeed(familyHistory.familyRelatives);
			dellShowContent(familyHistory);
		}
		/*var arrayTemp = exposureHistory.exposurecode;
		if(arrayTemp==""){
			$('#no').prop('checked',true);
			return ;
		}
		$('#yes').prop('checked',true);
		var strs = arrayTemp.split("|");
		for(var i=0;i<strs.length-1;i++){
			$("td span input[value='"+strs[i]+"']").prop('checked',true);
		}
		$('td span input').removeAttr('disabled','disabled');*/
//    alert(insurance);

		/*		BindClickWithInputShow(".insurance input[value='1']",".insurance input[type=text]","${dean}/img/card_bg");
		 $(".insurance input[value=1]").click( function(){BindClickWithInputShow(".insurance input[value='1']",".insurance input[type=text]","${dean}/img/card_bg")});
		 $(".insurance input[type=text]").focus(function(){textDefultShow(".insurance input[type=text]",true)});
		 $(".insurance input[type=text]").blur(function(){textDefultShow(".insurance input[type=text]",false)});*/
	});

	function getFamilyCode(familyCodeNum){
		if(familyCodeNum==1){
			dataNum="1";
			return;
		}
		if(familyCodeNum==2){
			dataNum="2";
			return;
		}
		if(familyCodeNum==3){
			dataNum="8";
			return;
		}
		if(familyCodeNum==4){
			dataNum="7";
			return;
		}
	}

	function getFamilyMemberDiseas(rowId){
		var temp=""
		if($("#Yes"+rowId).prop("checked")){
			$("#relation"+rowId+"  input[type=checkbox]:checked").each(function(){
				temp = temp +$(this).val()+"|";
			});
		}
		return temp;
	}

	function buildData(data){
		for(var i=1;i<=4;i++){
//			data[i-1]=new Object();
			getFamilyCode(i);
			data["allList["+(i-1)+"].idCard"]= "${idCard}";
			data["allList["+(i-1)+"].familyRelatives"]= dataNum;
			data["allList["+(i-1)+"].disease"]= getFamilyMemberDiseas(i);
			/*data[i-1]["idCard"] = "${idCard}";
			data[i-1]["familyRelatives"] = dataNum;
			data[i-1]["disease"] = getFamilyMemberDiseas(i);*/
		}
	}

	function saveData(){
		var data = new Object();
		buildData(data);
//		alert("xyc");
		jQuery.ajax({
			url :'${ctx}/web/patient/familyHistory/SaveOrUpdata',
			type : "post",
			data:data,
			cache : false,
			dataType : "json",
			success : function(data){
				alert("提交完成");
			}
		});
	}
</script>
</body>
</html>
